package com.kmzx.one.project.service.impl;

import com.kmzx.one.common.utils.UUIDGenerator;
import com.kmzx.one.project.mapper.SimpleMapper;
import com.kmzx.one.project.service.UserLicenseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Project one
 * @Author: carol
 * @Date: 2020/9/4-15:21
 */
@Component
public class UserLicenseServiceImpl implements UserLicenseService {

    @Autowired
    SimpleMapper simpleMapper;

    @Override
    public void insertUserLicense(String userId) {
        String id = UUIDGenerator.generate();
        Date date = new Date();
        simpleMapper.insertUserLicense(id, userId, date);
    }

    @Override
    public int checkHasUserLicense(String userId) {
        int notRead = simpleMapper.checkHasLicenseNotRead(userId);
        if (notRead > 0) {
            return 1;
        }
        return 0;
    }
}
